home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15665 < prev    next >
Encoding:
Text File  |  1996-08-05  |  842 b   |  40 lines

  1. Path: csus.edu!news
  2. From: wleong@sfsu.edu (Jerry Leong)
  3. Newsgroups: comp.lang.c
  4. Subject: How to pass function as arg?
  5. Date: Sat, 20 Apr 1996 23:56:19 GMT
  6. Organization: San Francisco State University
  7. Message-ID: <317937f7.325108@news.csus.edu>
  8. NNTP-Posting-Host: wleong@pluto.sfsu.edu
  9.  
  10. Please don't flame me for asking this question as I have read the faq,
  11. the newsgroup & I still couldn't find a satisfying answer.
  12.  
  13. I couldn't quite figure out how to do this. Below is the pseudo-code :
  14.  
  15. void do_something(void)
  16. {
  17. }
  18.  
  19. void call_this(void func)
  20. {
  21.    func();
  22. }
  23.  
  24. main()
  25. {
  26.   void (*fp)() = do_something();
  27.   call_this(fp);
  28. }
  29.  
  30. Okay, I am quite sure that I got the main() part right. But I'm not
  31. sure how
  32. to declare the call_this(func) part. Your pointer is greatly
  33. appreciated.
  34.  
  35. Thanx in advance.
  36.  
  37. p/s: Could this be another good topic for FAQ??
  38.  
  39.  
  40.